/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package numberpickerfx.logic;

import java.util.ArrayList;

/**
 *
 * @author zengchen
 */
public class RandomNumberNoRepeat extends RandomNumber{
    protected ArrayList<Integer> list;
    private int size;
    public RandomNumberNoRepeat(int min, int max) {
        super(min, max);
        list = new ArrayList<>();
        size = max - min + 1;
    }
    
    @Override
    public int getNumber(){
        if(list.size() == size - 1)
            return -1;
        int num = 0;
        for(num = super.getNumber(); list.contains(num); num = super.getNumber());
        list.add(num);
        return num;
    }
}
